﻿@using EasyWeb.Services
@model EWConfigurationLanguageModel
@{
    List<SelectListItem> items = null;

    if (!Model.Value.UseBrowserSetting)
    {
        items = new List<SelectListItem>();

        var all = ((IEWCultureService)EWServiceProviderManager.ServiceProvider.GetService(typeof(IEWCultureService))).All.OrderBy(m => m.Culture.Name);

        foreach (var item in all)
        {
            var culture = item.Culture;
            items.Add(new SelectListItem()
            {
                Text = string.Format("{0} ({1})", culture.DisplayName, culture.NativeName),
                Value = culture.Name,
                Selected = StringComparer.OrdinalIgnoreCase.Compare(culture.Name, Model.Value.DefaultLanguage) == 0
            });
        }
    }
}
<div class="easyweb-ewdefaultlanguage">
    @if (Model.Value.UseDefault)
    {
        @Html.LabelFor(m => m.Value.UseDefault, EWWebResources.Configuration_Language_Default)
        @Html.CheckBoxFor(m => m.Value.UseDefault, new { disabled = "disabled" })
    }
    else if (Model.Value.UseBrowserSetting)
    {
        @Html.LabelFor(m => m.Value.UseBrowserSetting, EWWebResources.Configuration_Language_Client)
        @Html.CheckBoxFor(m => m.Value.UseBrowserSetting, new { disabled = "disabled" })
    }
    else
    {
        @Html.LabelFor(m => m.Value.DefaultLanguage, EWWebResources.Configuration_Language_Value)
        @Html.DropDownListFor(m => m.Value.DefaultLanguage, items, new { disabled = "disabled" })
    }
</div>
